home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1992 June: ROMin Holiday / ADC Developer CD (1992-06) (''ROMin Holiday'')_iso / Developer Connection - 06-1992.iso / Development Platforms / Apple II / Apple II Sample Code / APW.SC / SC23SoundEx / SoundEx.inc.p < prev    next >
Encoding:
Text File  |  1990-06-24  |  26.3 KB  |  877 lines  |  [TEXT/pdos]

  1. { SoundEx -- Version 3.0 }
  2.  
  3. {******************************************************************************
  4. *
  5. * Developer Technical Support Apple II Sample Code
  6. *
  7. * doLoad:       This routine allocates a buffer and reads the desired file 
  8. *               into the buffer.   If a buffer has already been allocated, 
  9. *               It will be disposed.  Note that it also sets the global 
  10. *               variables BuffHndl and BuffSize.
  11. *
  12. * Inputs:       pathString contains the pathname of the file.
  13. * Outputs:      NONE
  14. * Calls:        NONE
  15. }
  16.  
  17. procedure doLoad(pathString : GSString255Ptr);
  18.  
  19. var
  20.     opRGS : OpenRecGS;
  21.     eofGS : EOFRecGS;
  22.     ioRGS : IORecGS;
  23.     rnRGS : RefNumRecGS;
  24.     
  25. begin
  26.     opRGS.pCount := 2;
  27.     opRGS.pathname := pathString;
  28.     OpenGS (OpRGS);
  29.  
  30.     eofGS.pCount := 2;
  31.     eofGS.refNum := opRGS.refnum;
  32.     GetEOFGS (eofGS);
  33.     BuffSize := trunc(eofGS.eof);
  34.     
  35.     if BuffHndl <> NIL then         
  36.         begin
  37.             HUnlock(BuffHndl);
  38.             DisposeHandle(BuffHndl);
  39.         end;
  40.  
  41.     BuffHndl := NewHandle (Buffsize, MyMemoryID, $C00C, NIL);
  42.     HLock(BuffHndl);
  43.     
  44.     iorGS.pCount := 4;
  45.     iorGS.refNum := opRGS.refnum;
  46.     iorGS.dataBuffer := BuffHndl^;
  47.     iorGS.requestCount := BuffSize;
  48.     ReadGS (ioRGS);
  49.  
  50.     rnRGS.pCount := 1;
  51.     rnRGS.refNum := opRGS.refnum;
  52.     CloseGS (rnRGS);
  53. end;
  54.  
  55. {******************************************************************************
  56. *
  57. * doLoadFile:   Puts up SFGetFile, calls doLoad with the desired pathName,
  58. *               updates the paramText for the staticText controls.
  59. *
  60. * Inputs:       NONE
  61. * Outputs:      NONE
  62. * Calls:        doLoad
  63. }
  64. procedure doLoadFile;
  65.  
  66. var
  67.     myReply : SFReplyRec2;
  68.     promptStr,
  69.     tempStr : String255;
  70.     x   : integer;
  71.  
  72. begin
  73.     myReply.nameRefDesc := refIsNewHandle;
  74.     myReply.pathRefDesc := refIsNewHandle;
  75.     promptStr := 'Select a Sound File to Load:';
  76.     SFGetFile2(
  77.         10, 35,
  78.         teRefIsPtr,
  79.         Ref(@promptStr),
  80.         NIL,            { filter proc }
  81.         NIL,            { type list   }
  82.         myReply
  83.     );
  84.  
  85.     if myReply.good then 
  86.         begin
  87.             {update the file name for display }
  88.             moveleft(Handle(myReply.nameRef)^^,tempStr,255);
  89.             tempStr[3] := tempStr[2];
  90.             
  91.             for x := 0 to length(tempStr) - 3 do   {moveleft won't do this}
  92.                 tempStr[x] := tempStr[x+3];
  93.                 
  94.             paramRec1.Str[1] := tempStr;                { set the paramText }
  95.             DrawOneCtl(GetCtlHandleFromID(OurWindow,curfileID));
  96.  
  97.             {set up the pathRef for the doLoad call }
  98.             moveleft(Handle(myReply.pathRef)^^,tempStr,255);
  99.             
  100.             for x := 0 to length(tempStr) - 2 do   {moveleft won't do this}
  101.                 tempStr[x] := tempStr[x+2];
  102.                 
  103.             doLoad(@tempStr);
  104.             
  105.             { set up the buffer pointer for display }
  106.             tempStr := '        ';
  107.             Long2Hex (longint(BuffHndl^), Ptr(Longint(@tempStr)+1),8);
  108.             
  109.             paramRec1.Str[2] := tempStr;
  110.             DrawOneCtl(GetCtlHandleFromID(OurWindow,loadedAtID));
  111.  
  112.             { set up the buffer size for display }
  113.             tempStr := '    ';
  114.             Long2Hex (BuffSize, Ptr(Longint(@tempStr)+1),4);
  115.             
  116.             paramRec1.Str[3] := tempStr;
  117.             DrawOneCtl(GetCtlHandleFromID(OurWindow,buffSizeID));
  118.  
  119.             DisposeHandle(Handle(myReply.nameRef));
  120.             DisposeHandle(Handle(myReply.pathRef));
  121.         end
  122. end;
  123.  
  124. {******************************************************************************
  125. *
  126. * setResult:    Updates the results of the last call.
  127. *
  128. * Inputs:       NONE
  129. * Outputs:      NONE
  130. * Calls:        NONE
  131. }
  132. procedure setResult;
  133.  
  134. var
  135.     resultStr : String;
  136.  
  137. begin
  138.     resultStr := '        ';
  139.     Long2Hex (CurCmdResult, @resultStr[1],8);
  140.     
  141.     paramRec1.Str[4] := resultStr;
  142.     DrawOneCtl(GetCtlHandleFromID(OurWindow,resultID));
  143.  
  144.     resultStr := '    ';
  145.     Int2Hex (CurCmdErr,@resultStr[1],4);
  146.     
  147.     paramRec1.Str[5] := resultStr;
  148.     DrawOneCtl(GetCtlHandleFromID(OurWindow,toolErrID));
  149. end;
  150.  
  151.  
  152.  
  153. {******************************************************************************
  154. *
  155. * setEditStr:   Places a Pascal string into a LineEdit control.
  156. *
  157. * Inputs:       updStr is the string to be set, and ctlItemID is the LineEdit
  158. *               control ID to set.
  159. *
  160. * Outputs:      NONE
  161. * Calls:        NONE
  162. }
  163. procedure setEditStr(updStr : String; ctlItemID : integer);
  164.  
  165. var
  166.     theCtl      : CtlRecHndl;
  167.     theLERec    : LERecHndl;
  168.  
  169. begin
  170.     theCtl := GetCtlHandleFromID(ourwindow, ctlItemID);
  171.     theLERec := LERecHndl(theCtl^^.ctlData);
  172.     
  173.     LESetSelect(0,256,theLERec);
  174.     LESetText(Ptr(@updStr[1]), length(updStr),
  175.               theLERec);
  176.     LESetSelect(0, 256, theLERec)  ;
  177.  
  178.     DrawOneCtl(theCtl);
  179. end;
  180.  
  181.  
  182. {******************************************************************************
  183. *
  184. * getEditStr:   Updates a Pascal string from the contents of a LineEdit control.
  185. *
  186. * Inputs:       ctlItemID is the LineEdit control ID to obtain the string from.
  187. * Outputs:      updStr contains the Pascal String.
  188. * Calls:        NONE
  189. }
  190. procedure getEditStr(var updStr : String; ctlItemID : integer);
  191.  
  192. var
  193.     theCtl   : CtlRecHndl;
  194.     textHndl : Handle;
  195.     textLen,x    : integer;
  196.  
  197. begin
  198.     theCtl := GetCtlHandleFromID(ourwindow, ctlItemID);
  199.     textHndl := LEGetTextHand(LERecHndl(theCtl^^.ctlData));
  200.     textLen := LEGetTextLen(LERecHndl(theCtl^^.ctlData));
  201.     moveleft(textHndl^^,updStr,textLen);
  202.     for x := textlen+1 downto 0 do
  203.         updStr[x+1] := updStr[x];
  204.     updStr[0] := chr(textLen);
  205. end;
  206.  
  207. {******************************************************************************
  208. *
  209. * getEditInt:   Updates an integer from the contents of a LineEdit control.
  210. *
  211. * Inputs:       ctlItem is the LineEdit control ID to obtain the value from.
  212. * Outputs:      the result is the integer value of the Hex String in the control.
  213. * Calls:        getEditStr
  214. }
  215. function getEditInt(ctlItem : integer) : integer;
  216.  
  217. var 
  218.     valStr : String;
  219.  
  220. begin
  221.     getEditStr(valStr,ctlItem);
  222.     getEditInt := Hex2Int ( @valStr[1], length(valStr));
  223. end;
  224.  
  225. {******************************************************************************
  226. *
  227. * getEditLong:  Updates a long from the contents of a LineEdit control.
  228. *
  229. * Inputs:       ctlItem is the LineEdit control ID to obtain the value from.
  230. * Outputs:      the result is the long value of the Hex String in the control.
  231. * Calls:        getEditStr
  232. }
  233. function getEditLong(ctlItem : integer) : longint;
  234.  
  235. var 
  236.     valStr : String;
  237.  
  238. begin
  239.     getEditStr(valStr,ctlItem);
  240.     getEditLong := Hex2Long ( @valStr[1], length(valStr));
  241. end;
  242.  
  243.  
  244. {******************************************************************************
  245. *
  246. * setEditInt:   Updates a LineEdit control to the hex string representation
  247. *               of an integer.
  248. *
  249. * Inputs:       value is the integer to be converted.
  250. *               ctlItem is the LineEdit control ID to receive the hex string.
  251. *               strLength is the desired length of the string.              
  252. * Outputs:      the result is the long value of the Hex String in the control.
  253. * Calls:        setEditStr
  254. }
  255. procedure setEditInt(value, ctlItem, strLength : integer);
  256.  
  257. var 
  258.     valStr : String;
  259.  
  260. begin
  261.     Int2Hex (value, @valStr[1], strLength);
  262.     valStr[0] := chr(strLength);
  263.     setEditStr(valStr, ctlItem);
  264. end;
  265.  
  266. {******************************************************************************
  267. *
  268. * setEditLong:  Updates a LineEdit control to the hex string representation
  269. *               of a long value passed to it. The string is assumed to be
  270. *               8 characters wide.
  271. *
  272. * Inputs:       value is the long to be converted.
  273. *               ctlItem is the LineEdit control ID to receive the hex string.
  274. * Outputs:      the result is the long value of the Hex String in the control.
  275. * Calls:        setEditStr
  276. }
  277. procedure setEditLong(value : longint; ctlItem:integer);
  278.  
  279. var 
  280.     valStr : String;
  281.  
  282. begin
  283.     Long2Hex (value, @valStr[1],8);
  284.     valStr[0] := chr(8);
  285.     setEditStr(valStr, ctlItem);
  286. end;
  287.  
  288.  
  289. {******************************************************************************
  290. *
  291. * setTargetCtl: After the proper controls have been "hilited", setTargetCtl
  292. *               will determine which should be active and make it the 
  293. *               current target control.
  294. *
  295. * Inputs:       NONE
  296. * Outputs:      NONE
  297. * Calls:        NONE
  298. }
  299. procedure setTargetCtl;
  300.  
  301. var theCtlID : integer;
  302.  
  303. begin
  304.     theCtlID := 0;
  305.     
  306.     if ctlHilite.docblk then
  307.         theCtlID := oscGenTypeID
  308.     else if ctlHilite.sndBlk then
  309.         theCtlID := waveStartID
  310.     else if ctlHilite.parm[1] then
  311.         theCtlID := parm1ID;
  312.  
  313.     if theCtlID <> 0 then
  314.         MakeThisCtlTarget (GetCtlHandleFromID(ourwindow,theCtlID));
  315. end;
  316.  
  317.  
  318. {******************************************************************************
  319. *
  320. * getDocBlk:    Returns the current DocRegParamBlock values from the 
  321. *               LineEdit controls.
  322. *
  323. * Inputs:       NONE
  324. * Outputs:      docBlock is the DOC register paramBlock.
  325. * Calls:        getEditInt
  326. }
  327. procedure getDocBlk(var docBlk : DocRegParamBlk);
  328.  
  329. begin
  330.     with docBlk do
  331.         begin
  332.             oscGenType  := getEditInt(oscGenTypeID);
  333.             freqLow1    := getEditInt(freqLow1ID);
  334.             freqHigh1   := getEditInt(freqHigh1ID);
  335.             vol1        := getEditInt(vol1ID);
  336.             tablePtr1   := getEditInt(tablePtr1ID);
  337.             control1    := getEditInt(control1ID);
  338.             tableSize1  := getEditInt(tableSize1ID);
  339.             freqLow2    := getEditInt(freqLow2ID);
  340.             freqHigh2   := getEditInt(freqHigh2ID);
  341.             vol2        := getEditInt(vol2ID);
  342.             tablePtr2   := getEditInt(tablePtr2ID);
  343.             control2    := getEditInt(control2ID);
  344.             tableSize2  := getEditInt(tableSize2ID);
  345.         end;
  346. end;
  347.     
  348. {******************************************************************************
  349. *
  350. * getSndBlk:    Returns the current SoundParamBlock values from the 
  351. *               LineEdit controls.
  352. *
  353. * Inputs:       NONE
  354. * Outputs:      sndBlk is the Sound paramBlock.
  355. * Calls:        getEditInt, getEditLong
  356. }
  357. procedure getSndBlk(var sndBlk : SoundParamBlock);
  358.  
  359. begin
  360.     with sndBlk do
  361.         begin
  362.             waveStart   := Ptr(getEditLong(waveStartID));
  363.             waveSize    := getEditInt(waveSizeID);
  364.             freqOffset  := getEditInt(freqOffsetID);
  365.             docBuffer   := getEditInt(docBufferID);
  366.             bufferSize  := getEditInt(bufferSizeID);
  367.             nextWavePtr := SoundPBPtr(getEditLong(nextWavePtrID));
  368.             volSetting  := getEditInt(volSettingID);
  369.         end;
  370. end;    
  371.  
  372. {******************************************************************************
  373. *
  374. * setDocBlk:    Updates the LineEdit controls based on the values in the 
  375. *               current DocRegParamBlock.
  376. *
  377. * Inputs:       docBlock is the DOC register paramBlock.
  378. * Outputs:      NONE
  379. * Calls:        setEditInt
  380. }
  381. procedure setDocBlk(docBlk : DocRegParamBlk);
  382.  
  383. begin
  384.     with docBlk do
  385.         begin
  386.             setEditInt(oscGenType, oscGenTypeID, 4);
  387.             setEditInt(freqLow1, freqLow1ID, 2);
  388.             setEditInt(freqHigh1, freqHigh1ID, 2);
  389.             setEditInt(vol1, vol1ID, 2);
  390.             setEditInt(tablePtr1, tablePtr1ID, 2);
  391.             setEditInt(control1, control1ID, 2);
  392.             setEditInt(tableSize1, tableSize1ID, 2);
  393.             setEditInt(freqLow2, freqLow2ID, 2);
  394.             setEditInt(freqHigh2, freqHigh2ID, 2);
  395.             setEditInt(vol2, vol2ID, 2);
  396.             setEditInt(tablePtr2, tablePtr2ID, 2);
  397.             setEditInt(control2, control2ID, 2);
  398.             setEditInt(tableSize2, tableSize2ID, 2);
  399.         end;
  400. end;
  401.     
  402. {******************************************************************************
  403. *
  404. * setSndBlk:    Updates the LineEdit controls based on the values in the 
  405. *               current SoundParamBlock.
  406. *               LineEdit controls.
  407. *
  408. * Inputs:       sndBlk is the Sound paramBlock.
  409. * Outputs:      NONE
  410. * Calls:        setEditInt, setEditLong
  411. }
  412. procedure setSndBlk(sndBlk : SoundParamBlock);
  413.  
  414. begin
  415.     with sndblk do
  416.         begin
  417.             setEditLong(longint(waveStart), waveStartID);
  418.             setEditInt(waveSize, waveSizeID, 4);
  419.             setEditInt(freqOffset, freqOffsetID, 4);
  420.             setEditInt(docBuffer, docBufferID, 4);
  421.             setEditInt(bufferSize, bufferSizeID, 4);
  422.             setEditLong(longint(nextWavePtr), nextWavePtrID);
  423.             setEditInt(volSetting, volSettingID, 4);
  424.         end;
  425. end;    
  426.  
  427. {******************************************************************************
  428. *
  429. * doExecute:    doExecute executes the Sound Tools command chosen in the 
  430. *               pop-up menu.  If necessary, it gets the values from the     
  431. *               correct parameters (or paramBlocks) and makes the call
  432. *               with them.  When the call is completed, it updates the
  433. *               affected parameters, including the staticText results.
  434. *
  435. * Inputs:       NONE
  436. * Outputs:      NONE
  437. * Calls:        setTargetCtl, getEditLong, getSndBlk, setSndBlk, getDocBlk, 
  438. *               setDocBlk, setEditLong, setResult
  439. }
  440. procedure doExecute;
  441.  
  442. var
  443.     docBlk : DocRegParamBlk;
  444.     sndBlk : SoundParamBlock;
  445.     parm1,
  446.     parm2,
  447.     parm3   : longint;
  448.     
  449. begin
  450.     setTargetCtl;                   { set the target control }
  451.  
  452.     { update the parameter values to be passed to the calls }
  453.     if ctlHilite.parm[1] then parm1 := getEditLong(Parm1ID);
  454.     if ctlHilite.parm[2] then parm2 := getEditLong(Parm2ID);
  455.     if ctlHilite.parm[3] then parm3 := getEditLong(Parm3ID);
  456.     
  457.     CurCmdErr := 0;     { reset the result values }
  458.     CurCmdResult := 0;
  459.  
  460.     case CurCmdNum of       { based on the pop-up selection, make the call }
  461.         SoundVersionID      : CurCmdResult := SoundVersion;
  462.         SoundToolStatusID   : CurCmdResult := ord(SoundToolStatus);
  463.         FFGeneratorStatusID : CurCmdResult := FFGeneratorStatus (parm1);
  464.         FFSoundDoneStatusID : CurCmdResult := ord(FFSoundDoneStatus (parm1));
  465.         FFSoundStatusID     : CurCmdResult := FFSoundStatus;
  466.         FFStartSoundID      :
  467.             begin
  468.                 getSndBlk(sndBlk);
  469.                 FFStartSound(trunc(parm1), @sndBlk);
  470.                 CurCmdErr := _toolErr;
  471.                 setSndBlk(sndBlk);
  472.             end;
  473.         FFStopSoundID       : FFStopSound(trunc(parm1))  ;
  474.         GetSoundVolumeID    : CurCmdResult := GetSoundVolume (parm1);
  475.         GetTableAddressID   : CurCmdResult := longint(GetTableAddress);
  476.         ReadRamBlockID      : ReadRamBlock ( Ptr(parm1), parm2, parm3);
  477.         SetSoundMIRQVID     : SetSoundMIRQV (parm1);
  478.         SetSoundVolumeID    : SetSoundVolume (parm1, parm2);
  479.         SetUserSoundIRQVID  : CurCmdResult := longint(SetUserSoundIRQV (ProcPtr(parm1)));
  480.         WriteRamBlockID     : WriteRamBlock (Ptr(parm1), trunc(parm2), trunc(parm3));
  481.         FFSetUpSoundID      :
  482.             begin
  483.                 getSndBlk(sndBlk);
  484.                 FFSetUpSound (parm1, @sndBlk);
  485.                 CurCmdErr := _toolErr;
  486.                 setSndBlk(sndBlk);
  487.             end;
  488.         FFStartPlayingID    : FFStartPlaying (parm1);
  489.         SetDOCRegID         :
  490.             begin
  491.                 getDocBlk(docBlk);
  492.                 SetDOCReg (docBlk)  ;
  493.                 CurCmdErr := _toolErr;
  494.                 setDocBlk(docBlk);
  495.             end;
  496.         ReadDOCRegID        :
  497.             begin
  498.                 getDocBlk(docBlk);
  499.                 ReadDOCReg (docBlk)  ;
  500.                 CurCmdErr := _toolErr;
  501.                 setDocBlk(docBlk);
  502.             end;
  503.     end;
  504.     
  505.     if CurCmdErr = 0 then CurCmdErr := _toolErr;
  506.  
  507.     if ctlHilite.parm[1] then setEditLong(Parm1, Parm1ID); { update the parameters }
  508.     if ctlHilite.parm[2] then setEditLong(Parm2, Parm2ID);
  509.     if ctlHilite.parm[3] then setEditLong(Parm3, Parm3ID);
  510.     
  511.     setResult;                  { update the result strings }
  512. end;
  513.  
  514. {******************************************************************************
  515. *
  516. * editToStatic: Replaces a LineEdit control with a staticText control.
  517. *
  518. * Inputs:       NONE
  519. * Outputs:      NONE
  520. * Calls:        getEditStr
  521. }
  522. procedure editToStatic(theCtlID : integer);
  523.  
  524. type 
  525.     StaticTextTemplate = RECORD
  526.         tpPCount    : integer;
  527.         tpID        : longint;
  528.         tpRect      : rect;
  529.         tpProcRef   : longint;
  530.         tpFlag      : integer;
  531.         tpMoreFlags : integer;
  532.         tpRefCon    : longint;
  533.         tpTextRef   : longint;
  534.         tpTextSize  : integer;
  535.     end;
  536.  
  537. var 
  538.     tempString  : String;
  539.     theCtl      : CtlRecHndl;
  540.     theTemplate : StaticTextTemplate;
  541.  
  542. begin
  543.     getEditStr(tempString,theCtlID);
  544.     parmArray[theCtlID] := tempString;
  545.     theCtl := GetCtlHandleFromID(ourWindow, theCtlID);
  546.     with theTemplate do
  547.         begin
  548.             tpPcount := 8;
  549.             tpID := theCtlID;
  550.             tpRect := theCtl^^.ctlRect;
  551.             tpProcRef := $81000000;
  552.             tpFlag := 0;
  553.             tpMoreFlags := $1000;
  554.             tpRefCon := 0;
  555.             tpTextRef := longint(@parmArray[theCtlID]) + 1;
  556.             tpTextSize := ord(parmArray[theCtlID][0]);
  557.         end;
  558.     DisposeControl(theCtl);
  559.     theCtl := NewControl2(ourWindow, 0, Ref(@theTemplate));
  560. end;
  561.  
  562. {******************************************************************************
  563. *
  564. * staticToEdit: Replaces a staticText control with a LineEdit control.
  565. *
  566. * Inputs:       theCtlID is the ID of the control to replace.
  567. * Outputs:      NONE
  568. * Calls:        NONE
  569. }
  570. procedure staticToEdit(theCtlID : integer);
  571.  
  572. Type 
  573.     EditLineTemplate = RECORD
  574.         tpPCount    : integer;
  575.         tpID        : longint;
  576.         tpRect      : rect;
  577.         tpProcRef   : longint;
  578.         tpFlag      : integer;
  579.         tpMoreFlags : integer;
  580.         tpRefCon    : longint;
  581.         tpMaxSize   : integer;
  582.         tpDefaultRef: longint;
  583.     end;
  584.  
  585. var 
  586.     theCtl      : CtlRecHndl;
  587.     theTemplate : EditLineTemplate;
  588.  
  589. begin
  590.     theCtl := GetCtlHandleFromID(ourWindow, theCtlID);
  591.     with theTemplate do
  592.         begin
  593.             tpPcount := 8;
  594.             tpID := theCtlID;
  595.             tpRect := theCtl^^.ctlRect;
  596.             tpProcRef := $83000000;
  597.             tpFlag := 0;
  598.             tpMoreFlags := $7000;
  599.             tpRefCon := 0;
  600.             tpMaxSize := 10;
  601.             tpDefaultRef := longint(@parmArray[theCtlID]);
  602.         end;
  603.     DisposeControl(theCtl);
  604.     theCtl := NewControl2(ourWindow, 0, Ref(@theTemplate));
  605. end;
  606.  
  607. {******************************************************************************
  608. *
  609. * doHilite:     Dispatches to editToStatic or staticToEdit to toggle a 
  610. *               control between a "hilited" and "unhilited" state.
  611. *
  612. * Inputs:       theCtlID is the ID of the control to replace.  hiliteVal
  613. *               determines whether the control is hilited or not.
  614. * Outputs:      NONE
  615. * Calls:        editToStatic, staticToEdit
  616. }
  617. procedure doHilite(hiliteVal : integer; theCtlID : integer);
  618.  
  619. begin
  620.     if hiliteVal = inactiveHilite then
  621.         begin
  622.             editToStatic(theCtlID);
  623.         end
  624.     else
  625.         begin
  626.             staticToEdit(theCtlID);
  627.         end;
  628.     MakeThisCtlTarget (GetCtlHandleFromID(ourwindow,oscGenTypeID));
  629.     DrawOneCtl(GetCtlHandleFromID(ourWindow, theCtlID));
  630. end;
  631.  
  632. {******************************************************************************
  633. *
  634. * hiliteSndBlk: Dispatches to doHilite to toggle the controls in the 
  635.                 Sound paramBlock between a "hilited" and "unhilited" state.
  636. *
  637. * Inputs:       NONE
  638. * Outputs:      NONE
  639. * Calls:        doHilite
  640. }
  641. procedure hiliteSndBlk;
  642.     
  643. var ctlID,
  644.     hiliteVal: integer;
  645.  
  646. begin
  647.     if ctlHilite.sndBlk then 
  648.         begin
  649.             hiliteVal := inactiveHilite;
  650.             ctlHilite.sndBlk := FALSE;
  651.         end
  652.     else 
  653.         begin
  654.             hiliteVal := noHilite;
  655.             ctlHilite.sndBlk := TRUE;
  656.         end;
  657.             
  658.                         
  659.     for ctlID := volSettingID downto waveStartID do
  660.         doHilite(hiliteVal,ctlID);
  661. end;
  662.  
  663. {******************************************************************************
  664. *
  665. * hiliteDocBlk: Dispatches to doHilite to toggle the controls in the 
  666. *               DOC Register paramBlock between a "hilited" and 
  667. *               "unhilited" state.
  668. *
  669. * Inputs:       NONE
  670. * Outputs:      NONE
  671. * Calls:        doHilite
  672. }
  673. procedure hiliteDocBlk;
  674.     
  675. var ctlID,
  676.     hiliteVal: integer;
  677.  
  678. begin
  679.     if ctlHilite.docBlk then 
  680.         begin
  681.             hiliteVal := inactiveHilite;
  682.             ctlHilite.docBlk := FALSE;
  683.         end
  684.     else 
  685.         begin
  686.             hiliteVal := noHilite;
  687.             ctlHilite.docBlk := TRUE;
  688.         end;
  689.                         
  690.     for ctlID := tableSize2ID downto oscGenTypeID do
  691.         doHilite(hiliteVal,ctlID);
  692. end;
  693.  
  694. {******************************************************************************
  695. *
  696. * hiliteParmX:  Dispatches to doHilite to toggle the controls for the 
  697. *               parameters between a "hilited" and "unhilited" state.
  698. *               It also is responsible for the naming of the parameters:
  699. *               
  700. *              -----------
  701. *              |$00000000|  genNumFFSynth           for a hilited parm
  702. *              -----------
  703. *               
  704. *               or
  705. *
  706. *               $00000000   Parm1                   for an unhilited parm
  707. *                   ^         ^
  708. *                   |         |____________________ the description
  709. *                   |______________________________ the parameter itself
  710. *               
  711. * Inputs:       parmNum is the index to the controlID.  parmString describes 
  712. *               the parameter.
  713. * Outputs:      NONE
  714. * Calls:        doHilite
  715. }
  716. procedure hiliteParmX(parmNum : integer; parmString : String);
  717.  
  718. var setString : String;
  719.     hiliteVal: integer;
  720.  
  721. begin
  722.     if ctlHilite.parm[parmNum] then 
  723.         begin
  724.             hiliteVal := inactiveHilite;
  725.             setString := 'ParmX';
  726.             setString[5] := chr(48 + parmNum);
  727.             ctlHilite.parm[parmNum] := FALSE;
  728.         end
  729.     else 
  730.         begin
  731.             hiliteVal := noHilite;
  732.             setString := parmString;
  733.             ctlHilite.parm[parmNum] := TRUE;
  734.         end;
  735.         paramRec1.Str[5 + parmNum] := setString;
  736.         DrawOneCtl(GetCtlHandleFromID(ourwindow, 223 + parmNum));
  737.         doHilite(hiliteVal,320 + parmNum);
  738. end;
  739.  
  740. {******************************************************************************
  741. *
  742. * doHiliteCtls: sets up the parameters for the call passed to it in cmdNum.
  743. *               
  744. * Inputs:       cmdNum is the call to set up for
  745. * Outputs:      NONE
  746. * Calls:        hiliteParmX, hiliteSndBlk, hiliteDocBlk
  747. }
  748. procedure doHiliteCtls(cmdNum : integer);
  749.  
  750. begin
  751.     case cmdNum of
  752.         SoundVersionID      :;
  753.         SoundToolStatusID   :;
  754.         FFGeneratorStatusID : hiliteParmX(1,'genNumber');
  755.         FFSoundDoneStatusID : hiliteParmX(1,'genNumber');
  756.         FFSoundStatusID     :;
  757.         FFStartSoundID      :
  758.             begin
  759.                 hiliteParmX(1,'genNumFFSynth');
  760.                 hiliteSndBlk;
  761.             end;
  762.         FFStopSoundID       : hiliteParmX(1,'genMask');
  763.         GetSoundVolumeID    : hiliteParmX(1,'genNumber');
  764.         GetTableAddressID   :;
  765.         ReadRamBlockID      :
  766.             begin
  767.                 hiliteParmX(3,'byteCount');
  768.                 hiliteParmX(2,'docStart');
  769.                 hiliteParmX(1,'destPtr');
  770.             end;
  771.         SetSoundMIRQVID     : hiliteParmX(1,'sMasterIRQ');
  772.         SetSoundVolumeID    :
  773.             begin
  774.                 hiliteParmX(2,'genNumber');
  775.                 hiliteParmX(1,'volume');
  776.             end;
  777.         SetUserSoundIRQVID  : hiliteParmX(1,'userIRQVector');
  778.         WriteRamBlockID     :
  779.             begin
  780.                 hiliteParmX(3,'byteCount');
  781.                 hiliteParmX(2,'docStart');
  782.                 hiliteParmX(1,'srcPtr');
  783.             end;
  784.         FFSetUpSoundID      :
  785.             begin
  786.                 hiliteParmX(1,'channelGen');
  787.                 hiliteSndBlk;
  788.             end;
  789.         FFStartPlayingID    : hiliteParmX(1,'genWord');
  790.         SetDocRegID         : hiliteDocBlk;
  791.         ReadDOCRegID        : hiliteDocBlk;
  792.     end;
  793. end;
  794.  
  795. {******************************************************************************
  796. *
  797. * doSndCmdPopUp:    Updates the current command and calls the hilite routines
  798. *                   to make the correct parameters available.
  799. *               
  800. * Inputs:       NONE
  801. * Outputs:      NONE
  802. * Calls:        doHiliteCtls, setTargetCtl
  803. }
  804. procedure doSndCmdPopUp;                { update the Current Command }
  805.  
  806. var 
  807.     theCtl : CtlRecHndl;
  808.     theCmd : integer;
  809.  
  810. begin
  811.     theCtl := GetCtlHandleFromID(ourwindow,sndCmdPopUp);
  812.     theCmd := theCtl^^.ctlValue;
  813.     doHiliteCtls(CurCmdNum);        { unhilite the controls for the previous command }
  814.     doHiliteCtls(theCmd);           { hilite the controls for the current command }
  815.     setTargetCtl;                   { Make the caret blink in the first available Ctl }
  816.     CurCmdNum := theCmd;            { update the global variable }
  817. end;
  818.  
  819. {******************************************************************************
  820. *
  821. * doInControl:  dispatches to the correct routine depending on the control 
  822. *               that was activated.
  823. *               
  824. * Inputs:       NONE
  825. * Outputs:      NONE
  826. * Calls:        doExecute, doLoadFile, doSndCmdPopUp
  827. }
  828. procedure doInControl;
  829.  
  830. var
  831.     theID       : Integer;
  832.  
  833. begin
  834.     theID := myEvent.wmTaskData4;               { what control ?}
  835.                               
  836.     case theID of
  837.         execbut:        doExecute;              { execute the current command }
  838.         loadbut:        doLoadFile;             { load a file }
  839.         sndCmdPopUp:    doSndCmdPopUp;          { handle the pop-up result }
  840.     end;
  841. end;
  842.  
  843. {******************************************************************************
  844. *
  845. * InitSoundEx:  Initializes all of the global variables.
  846. *               
  847. * Inputs:       NONE
  848. * Outputs:      NONE
  849. * Calls:        doExecute, doLoadFile, doSndCmdPopUp
  850. }
  851. procedure InitSoundEx;
  852.  
  853. var x : integer;
  854.  
  855. begin
  856.     for x := 0 to 9 do          { zero out the paramText Strings }
  857.             begin
  858.                 paramRec1.StrPtr[x] := @paramRec1.Str[x];
  859.                 paramRec1.Str[x] := '';
  860.             end;
  861.             
  862.     paramRec1.Str[0] := 'SoundVersion';     { set them how we want them }
  863.     paramRec1.Str[1] := 'none';
  864.     paramRec1.Str[2] := '00000000';
  865.     paramRec1.Str[3] := '0000';
  866.     paramRec1.Str[4] := '00000000';
  867.     paramRec1.Str[5] := '0000';
  868.     
  869.     ctlHilite.docBlk := TRUE;               { set up the default hilites for ctls }
  870.     ctlHilite.sndBlk := TRUE;
  871.     for x := 1 to 3 do ctlHilite.parm[x] := TRUE;
  872.     
  873.     SetCtlParamPtr ( @paramRec1)  ;         { now we can set the paramText }
  874.     
  875.     CurCmdNum := SoundVersionID;            { the current command is SoundVersionID } 
  876.     BuffHndl := NIL;                        { no buffer yet }
  877. end;